<template>
  <view class="callphone-list">
    <u-popup
      :show="popupShow"
      mode="bottom"
      :closeable="false"
      @close="noCancel"
      :safeAreaInsetBottom="false"
    >
      <view
        class="phone row"
        v-for="(item, index) in phoneList"
        :key="index"
        @click="callPhone(item)"
      >
        <u-icon name="phone-fill" color="#606266" size="20"></u-icon>
        <text>呼叫 {{ item | formatPhone }}</text>
      </view>
      <view class="cancel" @click="noCancel">取消</view>
    </u-popup>
  </view>
</template>

<script>
export default {
  name: "callphone-list",
  props: {
    popupShow: {
      type: Boolean,
      default: false,
    },
    phoneList: {
      type: Array,
      default: [],
    },
  },
  data() {
    return {};
  },
  methods: {
    callPhone(phone) {
      uni.makePhoneCall({
        phoneNumber: phone + "",
        fail: (res) => {
          //console.log('调用拨打电话功能失败！');
        },
      });
    },
    // 取消
    noCancel() {
      this.$emit("noCancel");
    },
  },
};
</script>

<style lang="scss">
/deep/.u-popup__content {
  background-color: transparent !important;
}
.callphone-list {
  text-align: center;
  color: #346bf6;
  font-size: 32rpx;

  .phone {
    padding: 20rpx 0;
    margin: 10rpx;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 8rpx;
    padding-left: 30rpx;

    text {
      margin-left: 30rpx;
    }
  }

  .cancel {
    margin: 10rpx;
    padding: 20rpx 0;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 8rpx;
  }
}
</style>
